package com.wzh.ojcodesandbox.controller;

import com.wzh.ojcodesandbox.codesandbox.impl.JavaNativeCodeSandbox;
import com.wzh.ojcodesandbox.model.ExecuteCodeRequest;
import com.wzh.ojcodesandbox.model.ExecuteCodeResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wzh
 */
@RestController
@RequiredArgsConstructor
public class MainController {

    private final JavaNativeCodeSandbox javaNativeCodeSandbox;

    @PostMapping("/executeCode")
    public ExecuteCodeResponse executeCode(@RequestBody ExecuteCodeRequest executeCodeRequest){
        if (executeCodeRequest==null){
            throw new RuntimeException("请求参数为空");
        }
       return javaNativeCodeSandbox.executeCode(executeCodeRequest);
    }

}
